<template>
    <div v-if="ishow">
        <el-button type="primary" @click="GoodsMainRef.showAdd(queryParams.jwApplydetailId, props.data)" class='mb-3'
            :disabled="SecurityChecktableData.length > 0">
            <!-- v-if="SecurityChecktableData.length == 0" -->
            <el-icon class="me-2">
                <Plus />
            </el-icon>
            新增
        </el-button>
        <el-table ref="SecurityChecktableDataRef" :data="SecurityChecktableData" show-overflow-tooltip
            style="width: 100%;" border>
            <el-table-column prop="areaname" label="办案区" min-width="140" />
            <el-table-column prop="getuserName" label="接收人" width="170" />
            <el-table-column prop="getdate" label="接收时间" min-width="170" />
            <el-table-column label="状态" prop="state">
                <template #default="scope">
                    <dict-tag :options="nj_goods_savestate" :value="scope.row.state" />
                </template>
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="140" align="center">
                <template #default="scope">
                    <el-button link type="primary" size="small"
                        @click="GoodsMainRef.showEdit(scope.row, 'Edit', props.data)" v-if="scope.row.state == 1">
                        <el-icon class="me-1">
                            <Edit />
                        </el-icon>
                        编辑
                    </el-button>
                    <el-button link type="primary" size="small"
                        @click="GoodsMainRef.showEdit(scope.row, 'See', props.data)" v-if="scope.row.state == 1">
                        <el-icon class="me-1">
                            <View />
                        </el-icon>
                        归还
                    </el-button>
                    <el-button link type="primary" size="small"
                        @click="GoodsMainRef.showEdit(scope.row, 'LastSee', props.data)" v-if="scope.row.state == 2">
                        <el-icon class="me-1">
                            <View />
                        </el-icon>
                        详情
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <GoodsMainAdd ref="GoodsMainRef" @getList="getLists" />
    </div>
</template>
<script setup>
import { getCurrentInstance, onMounted } from "vue";
import { ElMessageBox } from 'element-plus'
const { proxy } = getCurrentInstance()
import { GoodsMainList, GoodsMainEdit } from "@/api/ApplyDetail/ApplyDetail";

import GoodsMainAdd from "@/components/BAManageDetail/BAManageDetailActive/GoodsMainAdd.vue";

const { nj_goods_savestate, } = proxy.useDict('nj_goods_savestate',)
const props = defineProps({
    data: {
        type: Object,
        required: true, // 如果这个属性是必需的
    },
})

const ishow = ref(false)
const SecurityChecktableData = ref([])
const GoodsMainRef = ref({})
const queryParams = ref({
    jwApplydetailId: ''
})
const paging = ref({
    // 页码
    pageNum: 1,
    // 分页数量
    pageSize: 10
})

onMounted(() => {
    nextTick(() => {
        ishow.value = true
    })
    if (props.data && props.data.jw_applydetail_id) {
        // 调用接口获取列表数据
        queryParams.value.jwApplydetailId = props.data.jw_applydetail_id
        getLists();
    }
})

// 获取列表
const getLists = async () => {
    await GoodsMainList(queryParams.value, paging.value).then(res => {
        SecurityChecktableData.value = res.rows
    })
}


</script>
<style scoped>
:deep().el-table__header {
    width: 100% !important;
}
</style>